package com.sunqianhu.design_patterns_23.creational.singleton;

public class Singleton {
    //静态变量，初始为 null
    private static Singleton instance;

    //私有化构造函数
    private Singleton() {}

    //提供全局访问点，加上同步锁保证线程安全
    public static synchronized Singleton getInstance() {
        if (instance == null) {
            instance = new Singleton();
        }
        return instance;
    }
}
